package com.jt.controller;

import com.jt.pojo.User;
import com.jt.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
@CrossOrigin
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping("/getAll")
    public List<User> getAll(){
        return userService.getAll();
    }
    @DeleteMapping("/deleteUserById")
    public String deleteUser(Integer id){
        Integer i = userService.deleteUserById(id);
        return "删除了"+i+"条";
    }
    @PostMapping("/addUser")
    public String addUser(@RequestBody User user){
        Integer i = userService.addUser(user);
        return "新增"+i+"条";
    }
    @PutMapping("/updateUser")
    public String updateUser(@RequestBody User user){
        Integer i = userService.updateUser(user);
        return "修改了"+i+"条";
    }
}
